/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercises.day04.pt01.dao;

import exercises.day04.pt01.bean.Account_Holder;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Student
 */
public class Account_Holder_DAO extends Connector {

    public Account_Holder_DAO() {
    }

    public boolean register(Account_Holder ah) {
        try {
            //INSERT INTO ROOT.REGISTRATION (CFIRST_NAME, CLAST_NAME, CADDRESS, CACCOUNT_TYPE, MANNUAL_INCOME, CPHONE_NO) VALUES (5, 'Laurry', 'Helbert', 'Rock St.Seattle 234657', 'Fixed Deposit                 ', 450000.0, '0416348');

            PreparedStatement ps = this.getConn().prepareStatement("INSERT INTO ROOT.ACCOUNT_HOLDER (CACCOUNT_ID, "
                    + "CREGISTRATION_ID, MBALANCE) VALUES(?,?,?)");
            ps.setString(1, ah.getAhID());
            ps.setInt(2, ah.getRegistrationID());
            ps.setDouble(3, ah.getBalance());


            ps.executeUpdate();

        } catch (SQLException ex) {
            System.out.println(ex.toString());

            return false;
        }

        return true;
    }
}
